<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\controller;

/**
 * 前台首页控制器
 */
class Home extends AdminBase
{
    
    /**
     * 公司介绍
     */
    public function about()
    {
        
        $this->assign('info',$this->logicArticle->getArticleInfo(['category_id'=>25]));
        
        IS_POST && $this->jump($this->logicArticle->articleEdit($this->param,25,'home/about'));
        
        return $this->fetch('about');
    }
    
    
    /**
     * 企业成就
     */
    public function ourResult()
    {
        
        $this->assign('list', $this->logicOurResult->getOurResultList(['is_index'=>1],'*','sort'));
        
        return $this->fetch('result_list');
    }
    
    /**
     * 我们的业绩添加
     * @return type
     */
    public function resultAdd()
    {
        IS_POST && $this->jum($this->logicOurResult->indexResultEdit($this->param));
        
        $this->assign('info', []);
        
        return $this->fetch('result_edit');
    }
    
    /**
     * 保存企业成就
     */
    public function ourResultEdit()
    {         
        IS_POST && $this->jum($this->logicOurResult->indexResultEdit($this->param));
        
        $info = $this->logicOurResult->getOurResultInfo(['id' => $this->param['id']]);
 
        $this->assign('info', $info);
        
        return $this->fetch('result_edit');
    }

    
    /**
     * 成就图片
     * @return type
     */
    public function resultImg()
    {
        IS_POST && $this->jump($this->logicOurResult->resultImgEdit($this->param));
        
        $this->assign('info',$this->logicOurResult->getResultImg());
        
        return $this->fetch('img_edit');
    }
    
    
    /**
     * 咨询师
     */
    public function consultant()
    {
        $this->assign('list', $this->logicConsultant->getConsultantList(['is_index'=>1],'*','sort'));
        
        return $this->fetch('consultant_list');
    }
    
    /**
     * 咨询师添加
     * @return type
     */
    public function consultantAdd()
    {
        IS_POST && $this->jump($this->logicConsultant->indexConsultantEdit($this->param));
        
        return $this->fetch('consultant_edit');
    }
    
    /**
     * 保存咨询师
     */
    public function consultantEdit()
    {         

        IS_POST && $this->jump($this->logicConsultant->indexConsultantEdit($this->param));
        
        $info = $this->logicConsultant->getConsultantInfo(['a.id' => $this->param['id']]);
 
        $this->assign('info', $info);
        
        return $this->fetch('consultant_edit');
    }
    

    

    /**
    * 友情链接列表
    */ 
    public function friendshipList()
    {
        $where = $this->logicFriendship->getWhere($this->param);
        
        $d = $this->logicFriendship->getFriendshipList($where, '*', 'sort');
        
        $this->assign('list', $this->logicFriendship->getFriendshipList($where, '*', 'sort'));
        
        return $this->fetch('friendship_list');
    }
    
    /**
     * 编辑友情链接
     * @return type
     */
    
    public function friendshipEdit()
    {
        $this->friendshipCommon();
        
        $info = $this->logicFriendship->getFriendshipInfo(['a.id' => $this->param['id']]);
        
        !empty($info);
        
        $this->assign('info', $info);
        
        return $this->fetch('friendship_edit');
    }
    
    /**
     * 添加友情链接
     * @return type
     */
    public function friendshipAdd()
    {       
        $this->friendshipCommon();
        
        return $this->fetch('friendship_edit');
    }

    /**
     * 友情链接添加、编辑通用方法
     */
    public function friendshipCommon()
    {       
        IS_POST && $this->jump($this->logicFriendship->friendshipEdit($this->param));
    }
    
    
    /**
     * 更改友情链接状态  
     */
    public function setTeacherStatus()
    {
       $this->jump($this->logicAdminBase->setStatus('Consultant', $this->param));
    }
    
    /**
     * 排序
     */
    public function setTeacherdSort()
    {
        
        $this->jump($this->logicAdminBase->setSort('Consultant', $this->param));
    }
    
    
     /**
     * 更改友情链接状态  
     */
    public function setFriendStatus()
    {
       $this->jump($this->logicAdminBase->setStatus('Friendship', $this->param));
    }
    
    /**
     * 排序
     */
    public function setFriendSort()
    {
        
        $this->jump($this->logicAdminBase->setSort('Friendship', $this->param));
    }
}